package com.lpit.service.impl;

import com.lpit.constant.Constant;
import com.lpit.mapper.MessageMapper;
import com.lpit.pojo.Message;
import com.lpit.result.ResponseResult;
import com.lpit.service.PrivateMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PrivateMessageServiceImpl implements PrivateMessageService {
    @Autowired
    MessageMapper messageMapper;

    //查看私信
    @Override
    public ResponseResult<List<Message>> selectLetters(Message message) {
        List<Message> messages = messageMapper.selectLetters(message);
        return new ResponseResult<>(messages);
    }

    //删除私信
    @Override
    public ResponseResult<Integer> deleteLetters(Integer id) {
        Integer integer = messageMapper.deleteLetters(id);
        return new ResponseResult<>(200,integer, Constant.DELETE_SUCCESS);
    }

    //回复私信
    @Override
    public ResponseResult<List<Message>> insertLetters(Message message) {
        List<Message> messages = messageMapper.insertLetters(message);
        return new ResponseResult<>(messages);
    }

}
